package com.test.sdk.provider.controller;

import com.test.sdk.pojo.Game;
import com.test.sdk.provider.cache.GameCache;
import com.test.sdk.provider.exception.SdkException;
import com.test.sdk.provider.util.DigestUtils;
import com.test.sdk.provider.util.ErrorConstants;
import com.test.sdk.provider.util.ResponseTO;
import com.test.sdk.provider.util.SignUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class GameController {

    @RequestMapping("common/init.html")
    public ResponseTO init(int cpId, int seqnum) throws SdkException {
        //cpId=201&seqnum=1&sign=bb0d951fe0d837c962d70dc851bba735
//        String sign=request.getParameter("sign");
//        String mysign= DigestUtils.getMD5(SignUtil.signStr(request.getParameterMap())+"laomeng");
//        System.out.println(sign.equals(mysign));
        Game game = GameCache.getGame(cpId, seqnum);
//        if (game == null) {
//            throw new SdkException(ErrorConstants.GAME_NOT_EXIST);
//        }
        return new ResponseTO(true, game);
    }
}
